<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>安装{$app_info.name}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__LAYUI__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__LAYUI__/style/admin.css" media="all">
    <link rel="stylesheet" href="__LAYUI__/style/login.css" media="all">
    <style>
        .layui-form-item {
            margin-bottom: 3px;
        }
        #success {
            background: #009688;
            color: #fff;
            padding: 15px 20px;
            border-radius: 4px;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>

<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
 
<img src="__PUBLIC__/images/logo-touming.png" style="width: 120px">
     <h2>安装 {$app_info.name} v{$app_info.version}
               <br> <sub>{$app_info.version_alias}</sub></h2>        </div>
        <form class="layui-form layui-form-pane">

            <div id="success" style="display:none"></div>

            <div class="layui-form-item">
                <label class="layui-form-label">数据库地址</label>
                <div class="layui-input-block">
                    <input type="text" name="mysqlHost" value="127.0.0.1" lay-verify="required" autocomplete="off" placeholder="请输入数据库地址" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">数据库名</label>
                <div class="layui-input-block">
                    <input type="text" name="mysqlDatabase" value="ocenter" lay-verify="required" autocomplete="off" placeholder="请输入数据库名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">数据库用户</label>
                <div class="layui-input-block">
                    <input type="text" name="mysqlUsername" value="root" lay-verify="required" autocomplete="off" placeholder="请输入数据库用户名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">数据库密码</label>
                <div class="layui-input-block">
                    <input type="password" name="mysqlPassword" value="" lay-verify="required" autocomplete="off" placeholder="请输入数据库密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 30px">
                <label class="layui-form-label">数据表前缀</label>
                <div class="layui-input-block">
                    <input type="text" name="mysqlPrefix" value="oc_" lay-verify="required" autocomplete="off" placeholder="请输入数据表前缀" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">管理员名称</label>
                <div class="layui-input-block">
                    <input type="text" name="adminUsername" value="admin" lay-verify="required" autocomplete="off" placeholder="请输入管理员名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">管理员Email</label>
                <div class="layui-input-block">
                    <input type="text" name="adminEmail" value="admin@admin.com" lay-verify="required" autocomplete="off" placeholder="请输入管理员Email" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">管理员手机</label>
                <div class="layui-input-block">
                    <input type="text" name="adminMobile" value="" lay-verify="required" autocomplete="off" placeholder="用于接收重要提醒信息" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">管理员密码</label>
                <div class="layui-input-block">
                    <input type="password" name="adminPassword" value="" lay-verify="required" autocomplete="off" placeholder="请输入管理员密码" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 30px">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="adminPasswordConfirmation" value="" lay-verify="required" autocomplete="off" placeholder="请输入确认密码" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">点击安装</button>
            </div>
        </form>
    </div>

    <div class="layui-trans layadmin-user-login-footer">

        <p>© 2018 <a href="http://www.ocenter.cn/" target="_blank">ocenter.cn</a></p>
        <p>
            <span><a href="http://os.opensns.cn/book/index/read/id/30.html" target="_blank">开发文档</a></span>
            <span><a href="http://os.opensns.cn/forum/forum/12.html" target="_blank">开发者社区</a></span>
            <span><a href="http://www.ocenter.cn/" target="_blank">前往官网</a></span>
        </p>
    </div>

</div>

<script src="__LAYUI__/layui/layui.js"></script>
<script>
    layui.config({
        base: '__LAYUI__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user', 'jquery'], function () {
        var $ = layui.$
            , setter = layui.setter
            , admin = layui.admin
            , form = layui.form
            , router = layui.router()
            , search = router.search;

        form.render();

        //监听提交
        form.on('submit(LAY-user-login-submit)', function (data) {
            var $button = $('.layui-btn-fluid').text('安装中...').prop('disabled', true);

            var field = data.field;
            $.post("{:url('install/Install/index')}", {data: field}, function (res) {
                if (res.code === 1) {
                    $("#success").text("安装成功！").show();
                    $('<button class="layui-btn layui-btn-fluid" onclick="location:admin/login/login">访问后台</button>').insertAfter($button);
                    $button.remove();
                } else {
                    layer.msg(res.msg);
                    $button.text('点击安装').prop('disabled', false);
                }
            }, 'json');
            return false;
        });
    });
</script>
</body>
</html>